package com.frcdi.qms.web.controller.material;

import com.frcdi.qms.common.core.controller.BaseController;
import com.frcdi.qms.common.core.domain.AjaxResult;
import com.frcdi.qms.common.core.page.TableDataInfo;
import com.frcdi.qms.material.domain.OutboundRecord;
import com.frcdi.qms.material.service.OutboundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName OutboundController
 * @Author Mr.Han
 * @Description //TODO $
 * @create 2024/7/8 17:49
 **/
@RestController
@RequestMapping("/outbound")
public class OutboundController extends BaseController {
    @Autowired
    private OutboundService outboundService;

    @PostMapping("/add")
    public AjaxResult addOutboundRecord(@RequestParam Integer materialId, @RequestBody List<OutboundRecord> records) {
        outboundService.addOutboundRecord(materialId, records);
        return success("Outbound record added successfully");
    }

    @GetMapping("/list/{materialId}")
    public TableDataInfo getOutboundRecordsByMaterialId(@PathVariable Integer materialId) {
        return getDataTable(outboundService.getOutboundRecordsByMaterialId(materialId));
    }
}
